import request from '@/utils/request'

// 角色接口
export async function requestRolePage(data) {
  return request({
    url: `/plugin/role/roleGrid/${data.pageNo}/${data.pageSize}`,
    method: 'post',
    data: {
      pageSize: data.pageSize,
      goPage: data.pageNo,
      name: data.name,
    },
  })
}
export function requestRoleCreate(data) {
  return request({
    url: '/plugin/role/create',
    method: 'post',
    data,
  })
}
export function requestRoleUpdate(data) {
  return request({
    url: `/plugin/role/update`,
    method: 'post',
    data,
  })
}
export function requestRoleDelete(params) {
  return request({
    url: `/plugin/role/delete/${params.roleId}`,
    method: 'post',
  })
}
export function requestRoleBatchDelete(list) {
  return request({
    url: `/plugin/role/batchDelete`,
    method: 'post',
    data: list.map((item) => item.roleId),
  })
}
// 权限树
export function requestPermissionTree(params) {
  return request({
    url: `/api/menu/tree`,
    method: 'post',
    data: params,
  })
}
// 分配权限
export function requestRolePermissionAssign(params) {
  return request({
    url: `/plugin/role/bindMenu`,
    method: 'post',
    data: params,
  })
}
// 获取角色的权限
export function requestRolePermissionList(data) {
  return request({
    url: `/plugin/role/bindedMenu/${data.roleId}`,
    method: 'post',
    data,
  })
}

// 获取角色列表
export function requestRoleList(data) {
  return request({
    url: `/plugin/role/list`,
    method: 'post',
    data,
  })
}
